package com.tyk.bookstore.back.system.model.query;

import com.tyk.bookstore.back.system.model.type.MenuType;
import com.tyk.bookstore.back.system.valid.annotation.MenuFieldValid;
import com.tyk.bookstore.back.system.valid.group.TypeEqualsMenuItem;
import com.tyk.bookstore.back.system.valid.group.TypeEqualsSubMenu;
import com.tyk.bookstore.back.system.valid.provider.UpdateMenuQueryGroupSequenceProvider;
import com.tyk.bookstore.back.system.valid.type.MenuFieldValidType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.group.GroupSequenceProvider;

@Data
@GroupSequenceProvider(UpdateMenuQueryGroupSequenceProvider.class)
public class MenuUpdateQuery {
    @Schema(description = "菜单ID")
    @NotNull
    private Long id;

    @Schema(description = "父菜单ID")
    @NotNull
    private Long parentId;

    @Schema(description = "父菜单类型")
    @NotNull
    private MenuType type;

    @Schema(description = "路由名称")
    @NotBlank
    @MenuFieldValid(MenuFieldValidType.NAME)
    private String name;

    @Schema(description = "路由路径")
    @NotBlank
    @MenuFieldValid(value = MenuFieldValidType.PATH)
    private String path;

    @Schema(description = "路由重定向路径")
    @NotBlank(groups = {TypeEqualsSubMenu.class})
    @MenuFieldValid(value = MenuFieldValidType.REDIRECT, groups = {TypeEqualsSubMenu.class})
    private String redirect;

    @Schema(description = "组件路径")
    @NotBlank(groups = {TypeEqualsMenuItem.class})
    @MenuFieldValid(value = MenuFieldValidType.COMPONENT, groups = {TypeEqualsMenuItem.class})
    private String component;

    @Schema(description = "菜单名称")
    @NotBlank
    @MenuFieldValid(MenuFieldValidType.TITLE)
    private String title;

    @Schema(description = "菜单图标")
    @NotBlank
    @MenuFieldValid(MenuFieldValidType.ICON)
    private String icon;

    @Schema(description = "是否隐藏")
    @NotNull
    private Boolean hidden;

    @Schema(description = "是否缓存")
    @NotNull(groups = {TypeEqualsMenuItem.class})
    private Boolean keepAlive;
}
